package org.example
import org.apache.spark.sql.SparkSession
import org.apache.spark.rdd.RDD

object aaa {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder().master("local[*]").appName("sparkBase").getOrCreate()
    val sc = spark.sparkContext
    val rdd: RDD[Int] = sc.makeRDD(List(1, 2, 3, 4, 5), 1)
    val mapRDD = rdd.map(num => num + 2).sortBy(tp => tp).filter(_%2==0).take(1)
    mapRDD.foreach(System.out.println)


    val result = sc.textFile("C:\\Users\\Administrator\\Desktop\\Employee_salary_first_half.csv")
      .filter(!_.startsWith("EmpID"))
      .map { line =>
        val cols = line.split(",")
        (cols(1), cols(6).toInt)
      }
      .sortBy(-_._2)
      .take(3)

    result.foreach(println)

  }
}